package net.xxcxcxcx.xc_enhancedmob.render.particle.summon.magic.circle;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.api.EnvironmentInterface;
import net.fabricmc.api.EnvironmentInterfaces;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.util.math.Vec3d;
import net.xxcxcxcx.xc_enhancedmob.render.particle.ParticleHelper;

import static net.xxcxcxcx.xc_enhancedmob.register.ParticlesRegister.CUSTOM_DIRECTION_BASE_PARTICLE;

/**
 * 一个用于生成法阵的类
 */
@EnvironmentInterfaces(value = {@EnvironmentInterface(value = EnvType.CLIENT, itf = ClientWorld.class)})
public class BaseAttackParticle extends BaseSummonMagicCircleParticle {
    public BaseAttackParticle() {
        super();
    }

    public BaseAttackParticle(long t, Vec3d pos) {
        this(t, pos, 20);
    }

    public BaseAttackParticle(long t, Vec3d pos, int spawntime) {
        this(t, pos, spawntime, pos.add(0, 1, 0), 0.1f);
    }

    public BaseAttackParticle(long t, Vec3d pos, int spawntime, Vec3d target, float speedangleself) {
        super(t, pos, spawntime, target, speedangleself);
    }

    public BaseAttackParticle(PacketByteBuf buf) {
        read(buf);
    }

    //每秒中要执行的粒子效果
    @Override
    @Environment(value = EnvType.CLIENT)
    public void Dotick(ClientWorld clientWorld) {
        ParticleHelper.spawnCustomDirectionlistParticle(CUSTOM_DIRECTION_BASE_PARTICLE, false, false, pos.x, pos.y, pos.z, 0, 0, 0, 0, 2, spawntime, target, speedangleself, false);
        ParticleHelper.spawnCustomDirectionlistParticle(CUSTOM_DIRECTION_BASE_PARTICLE, false, false, pos.x, pos.y, pos.z, 0, 0, 0, 0, 3, spawntime, target, -speedangleself * 0.5f, false);
        use = true;
    }
}
